<template>

  <div style="width: 100%;">
    <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="150px" class="demo-ruleForm" size="mini"
             :inline="true">
      <el-form-item label="产品名称：" prop="name">
        <el-input v-model="ruleForm.name " clearable style="width: 220px"></el-input>
      </el-form-item>
      <el-form-item label="抽查理由：" prop="reasons">
        <el-input v-model="ruleForm.reasons " clearable style="width: 220px"></el-input>
      </el-form-item>
      <el-form-item label="抽查批次：" prop="batch">
        <el-input v-model="ruleForm.batch " clearable style="width: 220px"></el-input>
      </el-form-item>
      <el-form-item label="每批次抽样数量：" prop="number">
        <el-input v-model="ruleForm.number " clearable style="width: 220px"></el-input>
      </el-form-item>
      <el-form-item label="实施年份：" prop="year">
        <el-input v-model="ruleForm.year " clearable style="width: 220px"></el-input>
      </el-form-item>
      <el-form-item label="实施批次：" prop="batches">
        <el-input v-model="ruleForm.batches " clearable style="width: 220px"></el-input>
      </el-form-item>
      <el-form-item label="其他类别：" prop="other">
        <el-input v-model="ruleForm.other " clearable style="width: 220px"></el-input>
      </el-form-item>
      <el-form-item label="抽查实施细则：" prop="details">
        <el-input v-model="ruleForm.details " clearable style="width: 220px"></el-input>
      </el-form-item>
      <el-form-item label="授权证书有效期：" prop="authorization">
        <el-input v-model="ruleForm.authorization " clearable style="width: 220px"></el-input>
      </el-form-item>
      <el-form-item label="计量认证有效期：" prop="metering">
        <el-input v-model="ruleForm.metering " clearable style="width: 220px"></el-input>
      </el-form-item>
      <el-form-item label="实验室认可有效期：" prop="laboratory">
        <el-input v-model="ruleForm.laboratory " clearable style="width: 220px"></el-input>
      </el-form-item>
      <el-form-item label="上报检验结果时间：" prop="test">
        <el-input v-model="ruleForm.test " clearable style="width: 220px"></el-input>
      </el-form-item>
      <el-form-item label="申报经费预算：" prop="budget">
        <el-input v-model="ruleForm.budget " clearable style="width: 220px"></el-input>
      </el-form-item>
      <el-form-item label="抽查企业：" prop="enterprise">
        <el-input v-model="ruleForm.enterprise " clearable style="width: 220px"></el-input>
      </el-form-item>
    </el-form>
    <div align="center">
      <el-button type="primary" size="small" @click="submitForm('ruleForm')">确认</el-button>
      <el-button type="primary" size="small" @click="backPrePage">返回</el-button>
      <el-button type="primary" size="small" @click="Import">Excel导入</el-button>
      <!--<el-button type="primary" size="small" >企业库中选择</el-button>-->
      <template>
        <el-select v-model="value2" @blur="toChange" placeholder="企业库中选择">
          <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
      </template>

    </div>
  </div>
</template>
<script>

  export default {
    data() {
      return {
        ruleForm: {},
        rules: {},
        options: [
          {
            value:'选项1',
            label:'新型企业1',
            status: 0,
            name: '新型企业',
            reasons: '×××',
            batch: 12
          }],
        value2:''
      };
    },
    mounted() {
      document.onkeydown = function (e) {
        if (!e) {
          e = window.event;
        }
        if ((e.keyCode || e.which) == 13) {
          return false;
        }
      }
    },
    methods: {
      toChange(){
          this.ruleForm = {
            value:'选项1',
            label:'新型企业1',
            status: 0,
            name: '新型企业2',
            reasons: '×××',
            batch: 12
          }
        console.log(1)
        console.log(this.value2)

      },
      Import() {
        this.ruleForm = {
          status: 0,
          name: '新企业',
          reasons: '×××',
          batch: 20
        },
          this.value2 = ''
      },
      getOfficeList() {
      },
      submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            this.$router.push({path: '/task'});
            this.$store.commit('add_task_list', this.ruleForm);
          } else {
            return false;
          }
        });
      },
      backPrePage() {
        // carStore.commit('delete_tabs',this.$route.fullPath);
        this.$router.back()
      },
      //下拉框选中事件
      selectGet(vId) {//这个vId也就是value值
        let obj = {};
        obj = this.officeData.find((item) => {//这里的userList就是上面遍历的数据源
          return item.id === vId;//筛选出匹配数据
        });
        this.ruleForm.office_name = obj.name;
      }
    }
  }
</script>
<style lang="css" scoped>
</style>
